package south

import (
	"iot-base/common/cache"
	"iot-base/common/eventtype"
	"iot-base/common/mqtt"
	"iot-base/common/notify"
)

//处理告警
func handleEvent(client mqtt.IOTMQTTBroker, topic string, pCmd *mqtt.Cmd) {
	if pCmd.Body != nil {
		pEvent, ok := pCmd.Body.(*eventtype.Event)
		if ok && pEvent != nil {
			eventID := pEvent.EventID
			if eventID == "online" || eventID == "offline" {
				cache.SetThingState(pEvent.TID, eventID, pEvent.Time)
			}
			notify.RawEventEx(pEvent)
		}
	}
}
